package com.koicarp.university.graduate.web.controller.bigView;

import com.koicarp.university.graduate.service.service.graduateInfoManage.IGraduateInfoService;
import com.koicarp.university.graduate.service.service.graduateInfoManage.IGraduateStatusService;
import com.koicarp.university.graduate.service.service.report.IReportService;
import com.koicarp.university.graduate.service.service.report.ISchoolReportService;
import com.koicarp.university.graudate.common.constant.BaseConstant;
import com.koicarp.university.graudate.common.utils.UniversityResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.RoundingMode;
import java.text.DecimalFormat;

/**
 * @auther liutao
 * @Date 2020-11-18 10:28:06
 */
@Slf4j
@RestController
@RequestMapping("bigView")
@RequiredArgsConstructor
@Api(tags = "可视化数据控制层")
public class ViewController {

    private final IGraduateInfoService graduateInfoService;

    private final IGraduateStatusService graduateStatusService;

    private final ISchoolReportService schoolReportService;

    private final IReportService reportService;

    @PostMapping("getDegreeGraduateSum")
    @ApiOperation(value = "（今年，总数）查询系统毕业生数量")
    public UniversityResponse getDegreeGraduateSum(){
        UniversityResponse response=null;
        try{
            response = graduateInfoService.countDegreeGraduateSum();
        }catch (Exception e){
            log.error("查询",e);
            response = new UniversityResponse();
            response.code(BaseConstant.RESPONSE_CODE_FAILED_500);
            response.message(BaseConstant.RESPONSE_MESSAGE_OPR_FAILED);
        }
        return response;
    }

    @PostMapping("predictionGraduate")
    @ApiOperation(value = "根据往年的数据预测今年毕业生就业率")
    public UniversityResponse predictionGraduate(){
        UniversityResponse response=null;
        try{
            response = graduateStatusService.predictionGraduate();
        }catch (Exception e){
            log.error("查询",e);
            response = new UniversityResponse();
            response.code(BaseConstant.RESPONSE_CODE_FAILED_500);
            response.message(BaseConstant.RESPONSE_MESSAGE_OPR_FAILED);
        }
        return response;
    }
    @PostMapping("getStatusByTh")
    @ApiOperation(value = "毕业率前10学院", notes = "去年，与今年同比")
    public UniversityResponse getStatusByTh(){
        UniversityResponse response=null;
        try{
            response = graduateStatusService.getStatusByTh();
        }catch (Exception e){
            log.error("查询",e);
            response = new UniversityResponse();
            response.code(BaseConstant.RESPONSE_CODE_FAILED_500);
            response.message(BaseConstant.RESPONSE_MESSAGE_OPR_FAILED);
        }
        return response;
    }

    @PostMapping("getSpecialityTop")
    @ApiOperation(value = "今年专业薪水top10")
    public UniversityResponse getSpecialityTop(){
        UniversityResponse response=null;
        try{
            response = reportService.getSpecialityTop();
        }catch (Exception e){
            log.error("查询",e);
            response = new UniversityResponse();
            response.code(BaseConstant.RESPONSE_CODE_FAILED_500);
            response.message(BaseConstant.RESPONSE_MESSAGE_OPR_FAILED);
        }
        return response;
    }

    @PostMapping("getSalaryByAddress")
    @ApiOperation(value = "今年各个城市薪水分布图数据",notes = "城市维度，平均薪水")
    public UniversityResponse getSalaryByAddress(){
        UniversityResponse response=null;
        try{
            response = reportService.getSalaryByAddress();
        }catch (Exception e){
            log.error("查询",e);
            response = new UniversityResponse();
            response.code(BaseConstant.RESPONSE_CODE_FAILED_500);
            response.message(BaseConstant.RESPONSE_MESSAGE_OPR_FAILED);
        }
        return response;
    }
    @PostMapping("getGraduateNumByAddress")
    @ApiOperation(value = "今年毕业生数量城市分布top10",notes = "城市维度")
    public UniversityResponse getGraduateNumByAddress(){
        UniversityResponse response=null;
        try{
            response = reportService.getGraduateNumByAddress();
        }catch (Exception e){
            log.error("查询",e);
            response = new UniversityResponse();
            response.code(BaseConstant.RESPONSE_CODE_FAILED_500);
            response.message(BaseConstant.RESPONSE_MESSAGE_OPR_FAILED);
        }
        return response;
    }
    @PostMapping("getLeanByNowYear")
    @ApiOperation(value = "今年教学满意度",notes = "分五个等级")
    public UniversityResponse getLeanByNowYear(){
        UniversityResponse response=null;
        try{
            response = schoolReportService.getLeanByNowYear();
        }catch (Exception e){
            log.error("查询",e);
            response = new UniversityResponse();
            response.code(BaseConstant.RESPONSE_CODE_FAILED_500);
            response.message(BaseConstant.RESPONSE_MESSAGE_OPR_FAILED);
        }
        return response;
    }
    @PostMapping("countEnterHighByYear")
    @ApiOperation(value = "近五年升学人数",notes = "")
    public UniversityResponse countEnterHighByYear(){
        UniversityResponse response=null;
        try{
            response = graduateStatusService.countEnterHighByYear();
        }catch (Exception e){
            log.error("查询",e);
            response = new UniversityResponse();
            response.code(BaseConstant.RESPONSE_CODE_FAILED_500);
            response.message(BaseConstant.RESPONSE_MESSAGE_OPR_FAILED);
        }
        return response;
    }

}
